package br.skytef.stmanager.daos;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import br.skytef.stmanager.entities.ErroPlanilhaEntity;
import br.skytef.stmanager.utils.Pool;

public class ErroPlanilhaDAO{
	
	private Connection conexao;

	public boolean inserir(ErroPlanilhaEntity erro){
		conexao = Pool.getConnection();
		PreparedStatement preparedStmt;
		try {
			preparedStmt = conexao.prepareStatement("INSERT INTO erroPlanilha(controlPlanilha_idcontrolPlanilha, erro) VALUES (?,?);");
			preparedStmt.setInt(1, erro.getControlPlanilha_idcontrolPlanilha());
			preparedStmt.setString(2, erro.getErro());
			preparedStmt.execute();
			conexao.close();			
		} catch (SQLException e) {
			e.printStackTrace();
			return false;
		}		
		return true;		
	}
	public boolean delete(int idPlan){
		conexao = Pool.getConnection();
		PreparedStatement preparedStmt;
		try {
			preparedStmt = conexao.prepareStatement("DELETE FROM erroPlanilha WHERE controlPlanilha_idcontrolPlanilha ="+idPlan+";");
			preparedStmt.execute();
			conexao.close();			
		} catch (SQLException e) {
			e.printStackTrace();
			return false;
		}		
		return true;		
	}
}
